package com.example.ordersystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.ordersystem.entity.ShoppingCart;
import com.example.ordersystem.entity.vo.ShoppingCartVo;
import com.example.ordersystem.mapper.ShoppingCartMapper;
import com.example.ordersystem.service.ShoppingCartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {

    @Resource
    ShoppingCartMapper shoppingCartMapper;

    /**
     * 添加购物车
     * @param shoppingCart 购物车信息
     */
    @Override
    public void add(ShoppingCart shoppingCart) {
        shoppingCartMapper.insert(shoppingCart);
    }

    /**
     * 根据用户id查询购物车信息
     * @param id 用户id
     */
    @Override
    public List<ShoppingCartVo> select(String id) {
        return shoppingCartMapper.selectCart(id);
    }

    /**
     * 删除购物车信息
     * @param id 菜品在购物车中的id
     */
    @Override
    public void del(String id) {
        shoppingCartMapper.deleteById(id);
    }


}
